# Online Python - IDE, Editor, Compiler, Interpreter

def is_prime(n): 
    i=int(input())
    if n <= 1: return False 

    if n <= 3: return True 
    if n % 2 == 0 or n % 3 == 0: 
        return False i = 5
    while i * i <= n: 
        if n % i == 0 or n % (i + 2) == 0: 
            return False i += 6 return 
            True def closest_prime(num): offset = 0 
            while True: if is_prime(num - offset): 
                return num - offset 
                elif is_prime(num + offset): 
                    return num + offset offset += 1 words_to_numbers = { 'zero'

                                                                         : 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9 } def words_to_num(words): try: return int(''.join(str(words_to_numbers[word]) for word in words.split())) except KeyError: return "Wrong input" # Пример ввода input_words = "one two three" number = words_to_num(input_words) if isinstance(number, int) and 100 <= number <= 999: print(closest_prime(number)) else: print("Wrong input")
